<template>
  <el-dialog title="评论列表" :visible="show" @close="$emit('update:show', false)">
    <el-table :data="tableData" border>
      <el-table-column prop="nickname" label="昵称" />
      <el-table-column prop="content" label="内容" />
      <el-table-column prop="up_num" label="点赞数" />
      <el-table-column label="操作" width="180px" align="center">
        <template #default="{ row }">
          <el-button type="text" @click="delDiscuss(row, '选中的评论')"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </el-dialog>
</template>

<script>
import API from "@/api";
export default {
  props: {
    show: Boolean,
    params: Object,
  },
  data: () => ({
    tableData: [],
  }),
  watch: {
    show(val) {
      if (val) {
        API.getVillageDiscussList(this.params)
          .then(({ data }) => {
            this.tableData = data;
          })
          .catch((err) => {});
      }
    },
  },
  methods: {
    delDiscuss({id}) {
      API.delVillageDiscuss(id)
      .then(() => {
        this.$message.success('删除成功！');
      })
    }
  }
};
</script>

<style></style>
